﻿package core.ui.controls
{
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.text.*;

    public class MenuItem extends Sprite
    {
        private var bg:Sprite;
        private var callback:Function;

        public function MenuItem(param1:Function, param2:String, param3:Boolean = false, param4:String = "")
        {
            var _loc_5:TextField = null;
            this.name = param2;
            this.callback = param1;
            var _loc_6:* = 230;
            var _loc_7:* = new Matrix();
            _loc_7.createGradientBox(_loc_6 - 2, 18, 90 / (180 / Math.PI), 0, 0);
            this.bg = new Sprite();
            this.bg.graphics.beginGradientFill("linear", [3449586, 34534], [1, 1], [0, 255], _loc_7);
            this.bg.graphics.drawRect(0, 0, _loc_6 - 8, 18);
            this.bg.graphics.endFill();
            this.bg.alpha = 0;
            addChild(this.bg);
            var _loc_8:* = new TextField();
            _loc_8.defaultTextFormat = new TextFormat("Arial,Helvetica,San-serif", AppState.TextSize, 16777215, false, false, false, null, null, "left");
            _loc_8.multiline = false;
            _loc_8.selectable = false;
            _loc_8.autoSize = TextFieldAutoSize.LEFT;
            _loc_8.height = 16;
            _loc_8.text = U.RM(param2);
            if (param3)
            {
                _loc_8.appendText("...");
            }
            _loc_8.x = 5;
            addChild(_loc_8);
            if (param4 != "")
            {
                _loc_5 = new TextField();
                _loc_5.defaultTextFormat = new TextFormat("Arial,helvetica", 10, 15658734, false, false, false, null, null, "right");
                _loc_5.multiline = false;
                _loc_5.selectable = false;
                _loc_5.height = 16;
                _loc_5.width = _loc_6 - 50;
                _loc_5.text = param4;
                _loc_5.x = 40;
                _loc_5.y = 0;
                addChild(_loc_5);
            }
            this.addEventListener(MouseEvent.ROLL_OVER, this.MouseOver, false, 0, true);
            this.addEventListener(MouseEvent.ROLL_OUT, this.MouseOut, false, 0, true);
            this.addEventListener(MouseEvent.MOUSE_DOWN, this.MouseDown, false, 0, true);
            return;
        }// end function

        private function MouseDown(event:MouseEvent) : void
        {
            this.callback();
            return;
        }// end function

        private function MouseOver(event:MouseEvent) : void
        {
            this.bg.alpha = 1;
            return;
        }// end function

        private function MouseOut(event:MouseEvent) : void
        {
            this.bg.alpha = 0;
            return;
        }// end function

    }
}
